﻿<UserControl x:Class="FSquirrel.Views.RequestView"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:helper="clr-namespace:FSquirrel.Helpers"
        xmlns:ignore="http://www.ignore.com" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF45"
             xmlns:Properties="clr-namespace:FSquirrel.Properties" mc:Ignorable="d ignore" d:DesignWidth="200" d:DesignHeight="200"
             DataContext="{Binding RequestVM, Source={StaticResource Locator}}">

    <UserControl.Resources>
        <helper:FileSizeConverter x:Key="FileSizeConverter" />
        <helper:ExtensionIconConverter x:Key="ExtensionIconConverter" />

    </UserControl.Resources>
    <DockPanel>
        <StatusBar DockPanel.Dock="Bottom">
        <StatusBarItem>
        </StatusBarItem>
        <StatusBarItem HorizontalAlignment="Right">
            <StackPanel Orientation="Horizontal">
                <Separator/>
                    <TextBlock Text="{Binding Path=RequestListCollection.Count, StringFormat='Request Count : {0}'}" Margin="0,0,5,0"/>
                <Separator/>
                <TextBlock Text="{Binding Path=TotalSize, Converter={StaticResource FileSizeConverter}, StringFormat='Request Size : {0}'}"  Margin="0,0,5,0"/>
            </StackPanel>
        </StatusBarItem>
    </StatusBar>
    <Grid>
            <DataGrid AutoGenerateColumns="False" Height="Auto" HorizontalAlignment="Stretch" Name="dataGrid1" VerticalAlignment="Stretch" Width="Auto" CanUserAddRows="False" ItemsSource="{Binding Source={StaticResource Locator},Path=RequestVM.RequestListCollection}" IsReadOnly="False" >
            <DataGrid.Resources>
                <Style TargetType="{x:Type DataGridCell}">
                    <Setter Property="IsTabStop" Value="False" />
                </Style>
            </DataGrid.Resources>
            <DataGrid.AlternatingRowBackground>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#33667FF8" Offset="0.006" />
                    <GradientStop Color="White" Offset="0.983" />
                </LinearGradientBrush>
            </DataGrid.AlternatingRowBackground>
            <DataGrid.Columns>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.Header>
                        <CheckBox IsChecked="{Binding Source={StaticResource Locator},Path=RequestVM.AllCheckSelection}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="Checked">
                                        <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=RequestVM.CheckAllCommand}" CommandParameterValue="True"/>
                                </i:EventTrigger>
                                <i:EventTrigger EventName="Unchecked">
                                        <cmd:EventToCommand Command="{Binding Source={StaticResource Locator},Path=RequestVM.CheckAllCommand}" CommandParameterValue="False"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                        </CheckBox>
                    </DataGridTemplateColumn.Header>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                                <CheckBox IsChecked="{Binding Path=IsRequested}" Command="{Binding Source={StaticResource Locator},Path=RequestVM.SpacebarDataGridCommand}" CommandParameter="{Binding ElementName=dataGrid1,Path=SelectedItems}" ></CheckBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <!--<DataGridCheckBoxColumn Binding="{Binding Path=IsSelected}" CanUserReorder="False" IsReadOnly="False"></DataGridCheckBoxColumn>-->
                <DataGridTextColumn Binding="{Binding Path=Name}" Header="Name" CanUserReorder="False" IsReadOnly="True" />
                <DataGridTextColumn Binding="{Binding Path=Category}" Header="Category" CanUserReorder="False" IsReadOnly="True"  />
                <DataGridTextColumn Binding="{Binding Path=Size, Converter={StaticResource FileSizeConverter}}" Header="Size" CanUserReorder="False" IsReadOnly="True"   />
                <!--<DataGridTextColumn Binding="{Binding Path=Duration,  StringFormat={}{0:hh':'mm':'ss}}" Header="Duration" CanUserReorder="False" IsReadOnly="True" />-->
                <!--<DataGridTextColumn Binding="{Binding Path=Resolution}" Header="Resolution" CanUserReorder="False" IsReadOnly="True" />-->
                <!--<DataGridTemplateColumn  Header="Extension" CanUserReorder="False" IsReadOnly="True" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{Binding Path=Extension,Converter={StaticResource ExtensionIconConverter}}"  Margin="0,0,2,0" />
                                <TextBlock Text= "{Binding Path=Extension}" Margin="5,0,0,0" />
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>-->
                <!--<DataGridTextColumn Binding="{Binding Path=DateModified, StringFormat=d}" Header="Date Modified" CanUserReorder="False" Width="*" IsReadOnly="True" />-->
            </DataGrid.Columns>
            <DataGrid.InputBindings>
                    <KeyBinding Key="Space" Command="{Binding Source={StaticResource Locator},Path=RequestVM.SpacebarDataGridCommand}" CommandParameter="{Binding ElementName=dataGrid1,Path=SelectedItems}" ></KeyBinding>
            </DataGrid.InputBindings>
       
        </DataGrid>
    </Grid>
    </DockPanel>
</UserControl>
